#include "dbTag.h"

namespace db
{

Tag::Tag(string tag)
{
  Name = tag;
}

Tag::~Tag()
{
}
    
void Tag::addAppear(TreeVertex* vertex)
{
  Appears.push_back(vertex);
}

void Tag::remAppear(TreeVertex* vertex)
{
  for (int i = 0; i < Appears.size(); i++)
  {
    if (Appears[i] == vertex)
    {
      Appears[i] = Appears[Appears.size()-1];
      Appears.pop_back();
    }
  }
}

string Tag::getName()
{
    return Name;
}

int Tag::getAppearsCount()
{
  return Appears.size();
}

TreeVertex* Tag::getAppear(int id)
{
  if (id < Appears.size())
    return Appears[id];
  else
    return Appears[Appears.size()-1];
}

bool Tag::operator< (Tag & rTag)
{
  return Name < rTag.Name;
}

bool Tag::operator< (string rTag)
{
  return Name < rTag;
}
    
bool Tag::operator> (Tag & rTag)
{
  return Name > rTag.Name;
}

bool Tag::operator> (string rTag)
{
  return Name > rTag;
}
    
bool Tag::operator== (Tag & rTag)
{
  return Name == rTag.Name;
}

bool Tag::operator== (string rTag)
{
  return Name == rTag;
}

};